;;;
;;;
;;;	Author:
;;;		Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;
;;;     http://paracadd.com
;;;	All rights reserved.
;;;
;;;Logs the quit.
;;;
;;;Prior to DEFUN below (COMMAND ".undefine" "quit") is required or this DEFUN will not
;;;redefuine QSAVE (COMMAND ".undefine" "quit") can be executed from here or anywhere
;;;else as long as it is called before this DEFUN
;;;
(DEFUN c:quit (/ fstr)
  (IF (EQ (GETVAR "dbmod") 0)
    (PROGN
      (SETQ what_to_do 0); Drawing is not modified
      (IF debug_what_to_do NIL (LOAD "MYOPEN_FUN" "\nFile MYOPEN_FUN.LSP not loaded! "))
      (debug_what_to_do (STRCAT "Set what_to_do(6) to " (IF (EQ (TYPE what_to_do) 'INT) (ITOA what_to_do) (IF (EQ (TYPE what_to_do) 'STR) what_to_do "?"))))
    )
    (PROGN
      (SETQ what_to_do   ; Question "Save changes to...?" Returns: 6=Yes, 3=No, or 1=Cancel
           (DOS_MSGBOX
             (STRCAT "Save changes to "
                     (GETVAR "dwgprefix")
                     (GETVAR "dwgname")
             ) ;_ end of strcat
             "AutoCAD"
             5
             1
           ) ;_ end of dos_msgbox
      ) ;_ end of SETQ
      (IF debug_what_to_do NIL (LOAD "MYOPEN_FUN" "\nFile MYOPEN_FUN.LSP not loaded! "))
      (debug_what_to_do (STRCAT "Set what_to_do(7) to " (IF (EQ (TYPE what_to_do) 'INT) (ITOA what_to_do) (IF (EQ (TYPE what_to_do) 'STR) what_to_do "?"))))
    )
  ) ;_ end of IF
  (IF (EQ what_to_do 1)
    (PROGN
      (IF debug_what_to_do NIL (LOAD "MYOPEN_FUN" "\nFile MYOPEN_FUN.LSP not loaded! "))
      (debug_what_to_do "Set what_to_do(8) to NIL")
      (SETQ what_to_do nil)
      (PRINC "\n*CANCEL*")
      (PRINC)
    ) ;_ end of PROGN
    (PROGN
      (SETQ fstr "  Quit..................:  ")
      (IF dlog NIL (LOAD "dlog" "\nFile DLOG.LSP not loaded! "))
      (dlog)
      (IF align_lst
        (PROGN
          (SETQ num (LOAD_DIALOG "gpdgn"))
          (gate_dlg)
          (UNLOAD_DIALOG num)
          (PRINC)
        ) ;_ end of progn
        (PRINC)
      ) ;_ end of if
      (IF (EQ (GETVAR "dbmod") 0)
        (COMMAND ".quit")
        (PROGN
          (COND
            ((EQ what_to_do 6); "Save changes...?" Yes (or "Discard changes...?" No)
             (SETQ what_to_do nil)
             (COMMAND ".quit" "n")
            )
            ((EQ what_to_do 3); "Save changes...?" No (or "Discard changes...?" Yes)
             (SETQ what_to_do nil)
             (COMMAND ".quit" "y")
            )
          ) ;_ end of COND
        ) ;_ end of PROGN
      ) ;_ end of IF
    ) ;_ end of PROGN
  ) ;_ end of IF
) ;_ end of defun
(PRINC)
